import axios from 'axios';
/* 
封装axios
*/
const http = axios.create({
    timeout: 1000 * 30,
    baseURL: "http://124.71.219.15:8083//management_system/",
    withCredentials: true,
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
})
/* 
 请求拦截
*/
http.interceptors.request.use(
    config => {
        //这里判断本地是否存储了token
        // if (localStorage.getItem('token')) {
        //     config.headers.Authorization = localStorage.getItem('token')
        // }
        if (localStorage.getItem('datas')) {
            let a = JSON.parse(localStorage.getItem('datas'));
            let cookies = a[2]
            if (cookies) {
                config.headers['x-cookie'] = cookies
            }
        }
        return Promise.resolve(config)
    },
    err => {
        return Promise.reject(err)
    }
)

export default http